<template>
    <div class="container">
        <div class="item" v-for="item in list" :key="item.id" @click="toPage('pages/apanage_item_form', { id: item.id, name: item.name })">
            <div>{{ item.name }}</div>
            <span>{{ item.principal }} {{ item.phone }}</span>
        </div>
    </div>
</template>
<script>
import Empty from "../components/Empty.vue";
import { getItemByDeptIdAPI } from "../api/apanage";

export default {
    components: { Empty },
    data() {
        return {
            list: [],
        };
    },
    onShareAppMessage() {},
    onLoad(options) {
        let { id, title } = options;
        if (title) wx.setNavigationBarTitle({ title });

        getItemByDeptIdAPI({ id }).then((res) => {
            this.list = res.data;
        });
    },
    methods: {
        toPage(url, params) {
            this.$u.route({ url, params });
        },
    },
};
</script>
<style scoped lang="scss">
@import "../assets/scss/common.scss";

.container {
    min-height: 100vh;
    background-color: #fafafa;
    box-sizing: border-box;
    padding: 0 15px;
    .item {
        color: #0c92ff;
        font-size: 16px;
        line-height: 30px;
        border-bottom: 1px solid #ccc;
        box-sizing: border-box;
        white-space: nowrap; /* 防止文本换行 */
        overflow: hidden; /* 文本溢出容器时隐藏 */
        text-overflow: ellipsis; /* 使用省略号表示被隐藏的文本 */
        padding: 10px;
        span {
            color: #333;
        }
        &:last-child {
            border: none;
        }
    }
}
</style>
